package com_.dxy_test_.date_;

import com_.dxy_test_.utils_.DateTimeUtils;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;

/**
 * @Description 日期计数
 * @Author dangxianyue
 * @Date 2023/12/6 09:47
 */
public class DateCount {

    public static void main(String[] args) {

        // 开始和结束日期
        final LocalDate startDate = LocalDate.now().plusDays(1);
        final LocalDate endDate = LocalDate.parse("2024-01-20");

        // 节假日
        final LocalDate[] holiday = {
                LocalDate.parse("2024-01-01")
        };

        System.out.println(startDate.getDayOfWeek());

        final List<LocalDate> list = DateTimeUtils.getIntervalPerDay(startDate, endDate);
        list.forEach(System.out::println);

        final long workDateCount = list.stream().filter(o -> {
            final DayOfWeek dayOfWeek = o.getDayOfWeek();
            return !dayOfWeek.equals(DayOfWeek.SATURDAY) && !dayOfWeek.equals(DayOfWeek.SUNDAY)
                    && !Arrays.asList(holiday).contains(o);
        }).count();
        System.out.println("工作日天数：" + workDateCount);

    }
}
